package cfs.helper;

import java.math.BigDecimal;
import java.text.DecimalFormat;

public class Helper {

	public static final String PENDING_STATUS = "pending";
	public static final String COMPLETED_STATUS = "completed";
	private static DecimalFormat deFormatter2 = new DecimalFormat("#,##0.00");
	private static DecimalFormat deFormatter3 = new DecimalFormat("#,##0.000");

	public static Double valueRounding(double value, int scale) {
		BigDecimal bd = new BigDecimal(value);
		bd = bd.setScale(scale, BigDecimal.ROUND_HALF_EVEN);
		return bd.doubleValue();
	}

	public static String formatWith2Decimal(double d) {
		return deFormatter2.format(d);
	}

	public static String formatWith3Decimal(double d) {
		return deFormatter3.format(d);
	}

	public static long double2ToLong(double d) {
		return (long) (100 * d);
	}

	public static long double3ToLong(double d) {
		return (long) (1000 * d);
	}

	public static String longToDouble2String(long i) {
		return formatWith2Decimal((double) i / 100);
	}

	public static String longToDouble3String(long i) {
		return formatWith3Decimal((double) i / 1000);
	}

	public static void main(String[] args) {
		System.out.println(deFormatter2.format(5));
		System.out.println(deFormatter3.format(5));
	}
}
